<%--
  Created by IntelliJ IDEA.
  User: Li
  Date: 2021/12/2
  Time: 10:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 101 Template</title>
    <style>
        .box{
            margin: auto;
            padding: 20px;
            height: 600px;
            width: 1000px;
        }
        .form{
            margin-left:100px;
            margin-bottom: 10px;
        }
        .box2{
            text-align:right;
            margin-bottom:20px ;
        }
        .title-h1{
            margin:auto;
            width: 200px;
        }
        ul>li{
            display: inline-block;
            padding: 5px;
        }
        ul{
            text-align: right;
        }
        .pageNum{
            width: 40px;
            height: 18px;
        }
    </style>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="title-h1">
<h3>图书借阅系统</h3>
</div>
<div class="box">

<form action="/selAll" method="post" class="form">
    图书分类：<select name="booktype">
    <option value="-1">--请选择--</option>
    <option value="1">动漫</option>
    <option value="2">言情</option>
    <option value="3">玄幻</option>
</select>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    图书名称：<input type="text" placeholder="请输入图书名称" name="bookname">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    是否借阅：<select name="isborrowed">
    <option value="-1">--请选择--</option>
    <option value="1">是</option>
    <option value="0">否</option>
</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="submit" value="查询">
</form>
    <div class="box2">
        当前用户：${name}&nbsp;&nbsp;
        <a href="/logout">退出</a>
    </div>
<table class="table table-hover">
    <tr>
        <th>图书编号</th>
        <th>图书分类</th>
        <th>图书名称</th>
        <th>作者</th>
        <th>出版社</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${pageInfo.list}" var="book">
    <tr>
        <td>${book.bookcode}</td>
        <td>
            <c:if test="${book.booktype==1}">
                动漫
            </c:if>
            <c:if test="${book.booktype==2}">
                言情
            </c:if>
            <c:if test="${book.booktype==3}">
                玄幻
            </c:if>
        </td>
        <td>${book.bookname}</td>
        <td>${book.bookauthor}</td>
        <td>${book.publishpress}</td>
        <td>
            <c:if test="${book.isborrowed==1}">
                <a href="/upd?bookid=${book.bookid}&isborrowed=${book.isborrowed}">
                    <span style="color: red">已借阅</span>
                </a>
            </c:if>
            <c:if test="${book.isborrowed==0}">
                <a href="/upd?bookid=${book.bookid}&isborrowed=${book.isborrowed}">申请借阅</a>
            </c:if>
        </td>
    </tr>
    </c:forEach>
</table>
    <ul>
        <li>
            <c:if test="${pageInfo.hasPreviousPage}">
            <a href="/selAll?pageNum=${pageInfo.prePage}&booktype=${booktype}&bookname=${bookname}&isborrowed=${isborrowed}">上一页</a>
            </c:if>
        </li>
        <c:forEach begin="1" end="${pageInfo.pages}" var="i">
            <li
                    <c:if test="${i==pageInfo.pageNum}">
                        class="am-active"
                    </c:if>
            >
                <a href="/selAll?pageNum=${i}&booktype=${booktype}&bookname=${bookname}&isborrowed=${isborrowed}">${i}</a>
            </li>
        </c:forEach>
        <li>
            <c:if test="${pageInfo.hasNextPage}">
            <a href="/selAll?pageNum=${pageInfo.nextPage}&booktype=${booktype}&bookname=${bookname}&isborrowed=${isborrowed}">下一页</a>
            </c:if>
        </li>
        <li>共${pageInfo.pages}页</li>
        <li>
            <form action="/selAll">
                到第 <input type="text" name="pageNum" class="pageNum"> 页
                <input type="submit" value="确定">
            </form>

        </li>
    </ul>
</div>


<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</body>
</html>